Skip to content

Make site work with the Cloudflare OpenNext adapter #7383

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

dario-piotrowicz
Copy link
Member

@dario-piotrowicz dario-piotrowicz commented Jan 2, 2025

This PR applies changes to make it so that the site can be deployed to Cloudflare workers using the open-next Cloudflare adapter

The app does seem to work as intended for the most part:
Screenshot 2025-01-02 at 19 46 00

Deployment URL: https://nodejs-website.web-experiments.workers.dev


Warning

The PR is currently a single commit (ish), I am planning to force push (with --force-with-lease) any new changes and keep this a single commit PR for now (so that it's easier to manage and rebase), if that's too annoying problematic for reviewers please let me know and I can just push standard commits if strongly preferred


Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run npm run format to ensure the code follows the style guide.
  • I have run npm run test to check if all tests are passing.
  • I have run npx turbo build to check if the website builds without errors.
  • I've covered new added functionality with unit tests if necessary.

Copy link

vercel bot commented Jan 2, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
nodejs-org ❌ Failed (Inspect) Apr 24, 2025 4:43pm

@ovflowd
Copy link
Member

ovflowd commented Feb 1, 2025

@dario-piotrowicz do we have updates here? 👀

@dario-piotrowicz
Copy link
Member Author

Hey @ovflowd 👋

Sorry for keeping the PR lingering, there are a few smaller issues we addressed in our adapter (that I need to reflect here), and also ISR should be coming soon (@vicb can provide more context)

Besides that I just need to rebase the PR, the only significant issue remaining should be filesystem access, but I wanted to clarify that with you, I'll drop you a message today to clarify things

(PS: I hope the PR is not bothering you 🙇, if you want I can close it and reopen it when we're ready?)

@ovflowd
Copy link
Member

ovflowd commented Feb 16, 2025

Sorry for keeping the PR lingering, there are a few smaller issues we addressed in our adapter (that I need to reflect here), and also ISR should be coming soon (@vicb can provide more context)

This is awesome news. Excited to hear from @vicb

Besides that I just need to rebase the PR, the only significant issue remaining should be filesystem access, but I wanted to clarify that with you, I'll drop you a message today to clarify things

I believe we sorted that out on Slack 🖖

(PS: I hope the PR is not bothering you 🙇, if you want I can close it and reopen it when we're ready?)

Not at all <3

update the site application so that it can be build using the
Cloudflare OpenNext adapter (`@opennextjs/cloudflare`) and thus
deployed on Cloudflare Workers
Comment on lines +179 to +180
- `npx turbo cloudflare:preview` builds the website using the OpenNext Cloudflare adapter and runs the website locally in a server simulating the Cloudflare hosting (using the [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/))
- `npx turbo cloudflare:deploy` builds the website using the OpenNext Cloudflare adapter and deploys the website to the Cloudflare network (using the [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/))
Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ovflowd I know you asked not to have Cloudflare specific commands but I feel like this might be a good initial start for this and then consolidate the deployment scripts later on when the dust is fully settled

If you strongly disagree with this I'm happy to change this and try consolidate the scripts right off the bat

PS: I'll reach out to discuss the migration process, that might also influence how we want the scripts here to look like

@@ -164,6 +165,48 @@ This repository contains several scripts and commands for performing numerous ta

</details>

## Experimental Cloudflare Deployment
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've remmemerd to address #7383 (comment) 😄👍

@dario-piotrowicz dario-piotrowicz marked this pull request as ready for review April 24, 2025 15:53
@dario-piotrowicz dario-piotrowicz requested review from a team as code owners April 24, 2025 15:53
@@ -53,6 +53,7 @@
"eslint-plugin-import-x": "~4.10.0",
"eslint-plugin-no-relative-import-paths": "~1.6.1",
"prettier": "3.5.3",
"prettier-plugin-tailwindcss": "0.6.11"
"prettier-plugin-tailwindcss": "0.6.11",
"unrs-resolver": "^1.7.0"
Copy link
Member Author

@dario-piotrowicz dario-piotrowicz Apr 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the unrs-resolver dependency fixes an issue I was hitting in CI:

Oops! Something went wrong! :(

ESLint: 9.23.0

Error: Failed to load native binding

(related: unrs/unrs-resolver#56)

I must admit that I haven't really understood what the issue is here 🤔 if anyone has any idea on how to maybe better address/investigate it I'm more than happy to look into the issue 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actively use the dep?

If not, maybe add it to overrides for now, and we can investigate further?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actively use the dep?

No

If not, maybe add it to overrides for now, and we can investigate further?

Good call, yeah, sorry I keep forgetting the npm has overrides 😓

PS: I can keep investigating further but my worry is that this might just be fixed by the pnpm migration or if a solution is found for npm such can be invalidated by the pnpm migration 🤔

@dario-piotrowicz
Copy link
Member Author

@ovflowd the PR should be in a good enough shape for you to have another look when you've got a minute 🙏 🙂

dario-piotrowicz and others added 2 commits April 24, 2025 18:11
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Dario Piotrowicz <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Dario Piotrowicz <[email protected]>
Co-authored-by: Aviv Keller <[email protected]>
Signed-off-by: Dario Piotrowicz <[email protected]>
Comment on lines +6 to +7
"dev": "npm run build-blog-data:watch & sleep 1 && cross-env NODE_NO_WARNINGS=1 next dev",
"serve": "npm run build-blog-data:watch & sleep 1 && npm run dev",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this running the build twice? Once for serve, and again when serve calls dev?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants